home *** CD-ROM | disk | FTP | other *** search
- ; DOSSUB2I - general dos subroutine interface for interpretive BASIC
- ; Copyright 1983 Data Base Decisions
- ; CALL DOSSUB2I(STACK$,RETCD%,INTNO%,ES%,SI%,DI%,AH%,AL%,BH%,BL%,CH%,CL%,DH%,DL%)
- ; STACK$ is the stack area
- ; RETCD% is the error return code (0 if no error)
- ; INTNO% is the interrupt number (0 to 255)
- ; ES% is the argument corresponding to register ES
- ; SI% is the argument corresponding to register SI
- ; DI% is the argument corresponding to register DI
- ; AH% is the argument corresponding to register AH
- ; AL% is the argument corresponding to register AL
- ; BH% is the argument corresponding to register BH
- ; BL% is the argument corresponding to register BL
- ; CH% is the argument corresponding to register CH
- ; CL% is the argument corresponding to register CL
- ; DH% is the argument corresponding to register DH
- ; DL% is the argument corresponding to register DL
-
- cseg segment para public 'code'
- public dossub2i
- dossub2i proc far
- assume cs:cseg,ds:nothing,ss:nothing,es:nothing
- push bp
- mov bp,sp
-
- p10: ; use passed stack
- mov di,sp ; save orig sp
- mov si,[bp+32] ; point to stack$ arg
- mov al,[si] ; get length
- mov ah,0
- inc si
- add ax,[si] ; add start addr
- dec ax ; down by 1
- mov sp,ax ; new sp
- push di ; save orig sp on new stack - push 0
-
- p20: ; temporarily change fatal error vector
- push ds ; push 1
- push es ; push 2
- xor ax,ax
- mov ds,ax
- mov ax,[ds:90h] ; get fatal error ip
- push ax ; save ip - push 3
- mov ax,[ds:92h] ; get fatal error cs
- push ax ; save cs - push 4
- call p25 ; get ip - push 5a
-
- p25:
- a25 equ this byte
- pop bx ; ip in bx - pop 5a
- add bx,a50-a25
- mov ds:90h,bx ; ip of vector
- push cs ; set fatal error cs - push 5b
- pop ax ; set ds to cs - pop 5b
- mov ds:92h,ax ; cs of vector
- push es ; push 5c
- pop ds ; restore ds - pop 5c
-
- p30: ; set registers for call
- mov si,[bp+20] ; point to ah argument
- mov ah,[si]
- mov si,[bp+18] ; point to al argument
- mov al,[si]
- mov si,[bp+16] ; point to bh argument
- mov bh,[si]
- mov si,[bp+14] ; point to bl argument
- mov bl,[si]
- mov si,[bp+12] ; point to ch argument
- mov ch,[si]
- mov si,[bp+10] ; point to cl argument
- mov cl,[si]
- mov si,[bp+8] ; point to dh argument
- mov dh,[si]
- mov si,[bp+6] ; point to dl argument
- mov dl,[si]
- mov si,[bp+22] ; point to di argument
- mov di,[si]
- mov si,[bp+26] ; point to es argument
- push ax ; push 5d
- mov ax,[si] ; es arg in ax
- mov es,ax
- pop ax ; pop 5d
- mov si,[bp+24] ; point to si argument
- mov si,[si]
-
- p40: ; set up for call
- push ax ; push 5e
- push bx ; push 6
- mov bx,[bp+28] ; point to interrupt no
- mov al,[bx] ; interrupt in al
- call p45 ; push 7
-
- p45:
- a45 equ this byte
- pop bx ; ip in bx - pop 7
- add bx,a46-a45+1
- mov cs:[bx],al ; set interrupt
- pop bx ; pop 6
- pop ax ; pop 5e
- push bp ; save bp - bios bug - push 5f
- clc ; clear carry
-
- a46 equ this byte
- int 00h ; overlaid by intno%
- jc p48 ; dos 2.0 error
- jmp short p60 ; skip err control
-
- p48: ; dos 2.00 error
- pop bp ; pop 5f
- mov ah,1 ; indicate dos 2.0 error
- mov si,[bp+30] ; point to RETCD%
- mov [si],ax ; save error
- jmp short p70 ; bail out
-
- p50: ; handle fatal error
- a50 equ this byte
- sti ; interrupts back on
- mov ax,di ; get error code
- mov ah,0 ; error in al
- add sp,20 ; skip unneeded stack
- pop ds
- pop es
- add sp,6 ; skip rest of stack
- pop bp ; restore bp - bios bug - pop 5f
- mov si,[bp+30]
- mov [si],ax ; return error
- jmp short p70 ; restore orig vector
-
- p60: ; return register values
- pop bp ; restore bp - bios bug - pop 5f
- push si ; save for later - push 5g
- mov si,[bp+20] ; point to ah argument
- mov [si],ah
- mov si,[bp+18] ; point to al argument
- mov [si],al
- mov si,[bp+16] ; point to bh argument
- mov [si],bh
- mov si,[bp+14] ; point to bl argument
- mov [si],bl
- mov si,[bp+12] ; point to ch argument
- mov [si],ch
- mov si,[bp+10] ; point to cl argument
- mov [si],cl
- mov si,[bp+8] ; point to dh argument
- mov [si],dh
- mov si,[bp+6] ; point to dl argument
- mov [si],dl
- pop ax ; get returned si in ax - pop 5g
- mov si,[bp+24] ; point to si argument
- mov [si],ax
- mov ax,es ; get returned es in ax
- mov si,[bp+26] ; point to es argument
- mov [si],ax
- mov si,[bp+22] ; point to di argument
- mov [si],di
-
- p70: ; reset fatal error vector
- xor ax,ax
- mov ds,ax
- pop ax ; re-set fatal error vector - pop 4
- mov ds:92h,ax ; restore original cs
- pop ax ; pop 3
- mov ds:90h,ax ; restore original ip
- pop es ; pop 2
- pop ds ; pop 1
-
- p80: ; return to caller
- pop di ; get orig sp - pop 0
- mov sp,di ; back to orig stack
- pop bp ; return to caller
- ret 28
-
- dossub2i endp
- cseg ends
- end
-